<?php
class Tv_Arte_Helpers_Action_Display extends Zend_Controller_Action_Helper_Abstract
{
    /**
     * Disable view rendering
     * 
     * @return  Tv_Arte_Helpers_Action_Display
     */
    public function noView()
    {
        $this->_actionController->getHelper('ViewRenderer')->setNoRender(true);
        return $this;
    }
    /**
     * Disable layout rendering
     * 
     * @return  Tv_Arte_Helpers_Action_Display 
     */
    public function noLayout()
    {
        Zend_Layout::getMvcInstance()->disableLayout();
        return $this;
    }
    /**
     * Change layout
     *
     * @param   String $name
     * @return  Tv_Arte_Helpers_Action_Display 
     */
    public function setLayout($name)
    {
        $this->_actionController->getHelper('Layout')->setLayout($name);
        return $this;
    }
    /**
     * Disable view and layout rendering
     * 
     * @see     Tv_Arte_Helpers_Action_Display::noDisplay()
     * @see     Tv_Arte_Helpers_Action_Display::noLayout()
     * @return  Tv_Arte_Helpers_Action_Display 
     */
    public function none()
    {
        return $this->noView()->noLayout();
    }
    /**
     * Detect and handle by context
     * If Ajax, disables layout
     * 
     * @return  Tv_Arte_Helpers_Action_Display 
     */
    public function autoContext()
    {
        $httpRequest = $this->_actionController->getRequest();/* @var $httpRequest Zend_Controller_Request_Http */
        if ($httpRequest->isXmlHttpRequest()) {
            $this->noLayout();
        }
        return $this;
    }
}